package computerPlayer;

import java.awt.Color;
import java.util.List;
import java.util.Random;

import miniMax.TicTacToeFramework;

public class RandomPlayer extends Player {
	
	private TicTacToeFramework game;
	private final static String playerChar = "R"; 
	private final static String playerName = "Random"; 

	public RandomPlayer(TicTacToeFramework ticTacToe, Player otherPlayer) {
		super(playerChar, playerName);
		this.game = ticTacToe;
		super.setColor(Color.MAGENTA);
	}

	public Integer call() throws Exception {
		return makeMove();
	}

	@Override
	public int makeMove() {
		return returnRandom(game.possFields());
	}
	
	private int returnRandom(List<Integer> moves) {
		Random r = new Random();
		int next = r.nextInt(moves.size());
		return moves.get(next);
	}

	@Override
	public void reset(TicTacToeFramework game) {
		this.game = game;			
	}

	public void run() {
		// TODO Auto-generated method stub
		
	}


}
